<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>成绩判断</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="wd">
        <h1>您的成绩是：</h1>
        <compoent1 :score="48"></compoent1>
        <compoent1 :score="77"></compoent1>
        <compoent1 :score="60"></compoent1>
        <compoent1 :score="100"></compoent1>
    </div>

    <script>
        //组件
        Vue.component('compoent1', {
            props: ['score'],
            template: `
    <div>
        {{score}}分,{{testResult}}
        </div>
    `,
            computed: {

                testResult() {
                    var str = "";
                    if (this.score < 60) {
                        str = "不及格"
                    } else if (this.score < 90) {
                        str = "中等生"
                    } else if (this.score <= 100)
                        str = "优等生";
                    return str;
                }
            }

        })
        var vm = new Vue({
            el: "#wd",
            data: {},
            methods: {}
        })
    </script>
</body>

</html>